{php include wl_template('common/header');}
<script type="text/javascript" src="resource/js/lib/jquery-ui-1.10.3.min.js"></script>
<ul class="nav nav-tabs" id="myTab">
	<li class="active" ><a href="#tab_basic">基本信息</a></li>
	<li><a href="#tab_detail">简介详情</a></li>
	<!--<li><a href="#tab_concessions">促销方式</a></li>-->
	<li><a href="#tab_hexiao">配送方式</a></li>
	<!--<li  style="display:none"><a href="#tab_option">规格库存</a></li>-->
	<li><a href="#tab_share">分享设置</a></li>
	<li><a href="#tab_param">服务时间</a></li>
	<!--<li  style="display:none"><a href="#tab_level">阶梯/自选团</a></li>-->
	<!--<li style="display:none"><a href="#tab_luck">奖项设置</a></li>-->
</ul>
<div class="main">
	<form action="" method="post" class="form-horizontal form" id="form">
		<div class="tab-content">
			<div class="tab-pane  active" id="tab_basic">
				{php include wl_template('goods/goods_basic');}
			</div>
			<div class="tab-pane" id="tab_detail">
				<div class="panel panel-default">
					<div class="panel-heading">简介详情<a target="_blank" style="cursor:pointer; float:right; font-weight:bold;" href="http://doc.lexiangpingou.cn/releaseProduct.html#jjxq">图文说明>></a></div>
					<div class="panel-body">
						<div class="panel-body">
							{php include wl_template('goods/goods_detail');}
						</div>
					</div>
				</div>
			</div>
			<div class="tab-pane" id="tab_concessions">
				<div class="panel panel-default">
					<div class="panel-heading">促销方式<a target="_blank" style="cursor:pointer; float:right; font-weight:bold;" href="http://doc.lexiangpingou.cn/releaseProduct.html#cxfs">图文说明>></a></div>
					<div class="panel-body">
						<div class="panel-body">
							{php include wl_template('goods/goods_concessions');}
						</div>
					</div>
				</div>
			</div>
			<div class="tab-pane" id="tab_hexiao">
				<div class="panel panel-default">
					<div class="panel-heading">配送方式<a target="_blank" style="cursor:pointer; float:right; font-weight:bold;" href="http://doc.lexiangpingou.cn/releaseProduct.html#psfs">图文说明>></a></div>
					<div class="panel-body">
						<div class="panel-body">
							{php include wl_template('goods/goods_hexiao');}
						</div>
					</div>
				</div>
			</div>
			
			<div class="tab-pane" id="tab_option" {if !$isoption['status']} style="display:none"{/if}>
				<div class="panel panel-default">
					<div class="panel-heading">规格库存
					<a target="_blank" style="cursor:pointer; float:right; font-weight:bold;" href="http://v.youku.com/v_show/id_XMTc0OTkwNzY2MA==.html?from=s1.8-1-1.2&spm=a2h0k.8191407.0.0">视频演示>>
					<a target="_blank" style="cursor:pointer; float:right; margin-right:10px; font-weight:bold;" href="http://doc.lexiangpingou.cn/releaseProduct.html#ggkc">图文说明>></a>
					</div>
					<div class="panel-body">
						<div class="panel-body">
							{php include wl_template('goods/goods_option');}
						</div>
					</div>
				</div>
			</div>
			
			
			<div class="tab-pane" id="tab_level" {if !$isjieti['status']} style="display:none"{/if}>
				<div class="panel panel-default">
					<div class="panel-heading">阶梯团<a target="_blank" style="cursor:pointer; float:right; font-weight:bold;" href="http://doc.lexiangpingou.cn/releaseProduct.html#jtt">图文说明>></a></div>
					<div class="panel-body">
						<div class="panel-body">
							{php include wl_template('goods/goods_level');}
						</div>
					</div>
				</div>
			</div>
			
			<div class="tab-pane" id="tab_share">
				<div class="panel panel-default">
					<div class="panel-heading">分享设置</div>
					<div class="panel-body">
						<div class="panel-body">
							{php include wl_template('goods/goods_share');}
						</div>
					</div>
				</div>
			</div>
			<div class="tab-pane" id="tab_param">
				<div class="panel panel-default">
					<div class="panel-heading">服务时间(时间格式 例 08:00)</div>
					<div class="panel-body">
						<div class="panel-body">
							{php include wl_template('goods/goods_param');}
						</div>
					</div>
				</div>
			</div>
			<div class="tab-pane" id="tab_luck">
				<div class="panel panel-default">
					<div class="panel-heading">奖项设置</div> 
					<div class="panel-body">
						<div class="panel-body">
							{php include wl_template('goods/goods_luck');}
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="form-group col-sm-12">
			<input type="hidden" name="id" value="{$goods['id']}" />
			<input type="submit" name="submit" value="提交" class="btn btn-primary col-lg-1" />
			<input type="hidden" name="token" value="{$_W['token']}" />
		</div>
	</form>
	
</div>
<script>
/*var selltypes = document.querySelectorAll('input[name="goods[selltype]"]');
selltypes[0].addEventListener("click", function (ev) {document.getElementById("myTab").querySelectorAll("li")[7].style.display = "none";}, false);
selltypes[1].addEventListener("click", function (ev) {document.getElementById("myTab").querySelectorAll("li")[7].style.display = "none";}, false);
selltypes[2].addEventListener("click", function (ev) {document.getElementById("myTab").querySelectorAll("li")[7].style.display = "none";}, false);
selltypes[3].addEventListener("click", function (ev) {document.getElementById("myTab").querySelectorAll("li")[7].style.display = "block";}, false);
selltypes[4].addEventListener("click", function (ev) {document.getElementById("myTab").querySelectorAll("li")[7].style.display = "block";}, false);
if (selltypes[3].checked || selltypes[4].checked) {
	document.getElementById("myTab").querySelectorAll("li")[7].style.display = "block";
}
else {
	document.getElementById("myTab").querySelectorAll("li")[7].style.display = "none";
}*/
/*
var selltypes = document.querySelectorAll('input[name="goods[selltype]"]');
if (document.getElementById("myTab").querySelectorAll("li")[7] !== undefined) {
	selltypes[0].addEventListener("click", function (ev) {document.getElementById("myTab").querySelectorAll("li")[7].style.display = "none";}, false);
	selltypes[1].addEventListener("click", function (ev) {document.getElementById("myTab").querySelectorAll("li")[7].style.display = "none";}, false);
	selltypes[2].addEventListener("click", function (ev) {document.getElementById("myTab").querySelectorAll("li")[7].style.display = "none";}, false);
}
if (selltypes[3] !== undefined){
	selltypes[3].addEventListener("click", function (ev) {document.getElementById("myTab").querySelectorAll("li")[7].style.display = "block";}, false);
	if (selltypes[3].checked) {
	document.getElementById("myTab").querySelectorAll("li")[7].style.display = "block";
	}
	else {
		document.getElementById("myTab").querySelectorAll("li")[7].style.display = "none";
	}
}
if (selltypes[4] !== undefined){	
	selltypes[4].addEventListener("click", function (ev) {document.getElementById("myTab").querySelectorAll("li")[7].style.display = "block";}, false);
	if (selltypes[4].checked) {
		document.getElementById("myTab").querySelectorAll("li")[7].style.display = "block";
	}
	else {
		document.getElementById("myTab").querySelectorAll("li")[7].style.display = "none";
	}
}*/
function checkStoreVal() {
	if (document.getElementById("hasoption")){
		var option = document.getElementById("hasoption"),
			storeNum = document.querySelector("input[name='goods[gnum]']");
		if (document.getElementById("hasoption").checked) {
			var optionStocks = document.getElementsByClassName("option_stock"),
				len = optionStocks.length,
				sum = 0;
			for (var i = 0; i < len; i++) {
				sum += Number(optionStocks[i].value);
			}
			storeNum.value = sum;
		}
	}
}
function checkJttValue() {
	var price = document.querySelector('[name="goods[gprice]"]').value;
	var groupNum = document.querySelector('[name="goods[groupnum]"]').value;
	if (document.querySelector('input[value="2"][name="goods[group_level_status]"]').checked) {
		var gprice = document.querySelector(".param_value").value;
		var gnums = document.querySelectorAll(".param_title");
		var groupnum = gnums[gnums.length - 1].value;
		if (Number(price) == Number(gprice) && Number(groupNum) == Number(groupnum)) {
			return true;
		}
		else {
			return false;			
		}
	}
	else {
		return true;
	}
 }
$(function () {
	window.optionchanged = false;
	$('#myTab a').click(function (e) {
		e.preventDefault();//阻止a链接的跳转行为
		$(this).tab('show');//显示当前选中的链接及关联的content
	})
});
	$(function(){
		$('#form').submit(function(){
			var deliverytype= document.getElementsByName("goods[deliverytype]");
			for (var i=0; i < deliverytype.length; i++) {
				var value=deliverytype.item(i).value;
				console.log(value);
				if ((value=="2")&&deliverytype.item(i).checked){
					if($('#stores').html()=="") {
						util.message('请选择门店');
						return false;
					}
				}
			}

		checkStoreVal();
			if($('input[name="goods[gname]"]').val() == ''){
				util.message('请填写商品名称.');
				return false;
			}
			if($('input[name="goods[gname]"]').val().length > 30){
				util.message('为保证支付正常，项目名称字数不能大于30个字');
				return false;
			}
			if($('input[name="endtime"]').val() == ''){
				util.message('请填写项目时长');
				return false;
			}

			if($('input[name="goods[gimg]"]').val() == ''){
				util.message('请上传拍品图片.');
				return false;
			}
			if($('input[name="goods[gdesc]"]').val() == ''){
				util.message('请填写项目简介.');
				return false;
			}
			var hexiao = document.querySelector('a[href="#tab_hexiao"]');
		if (hexiao.parentNode.classList.contains("active")){
			var delivers = document.querySelectorAll("input[name='goods[deliverytype]'");
			var dispatchs = document.getElementById("dispatchs");
			var saler = document.getElementById("saler");
			var preCheck = false;
			if (delivers[1].checked || delivers[2].checked|| delivers[4].checked|| delivers[7].checked) {
				if (document.getElementById("dispatch").querySelectorAll(".input-group").length == 0) {
					util.tips("请填写快递模板");
					preCheck = true;
					return false;
				}
			}
			if (delivers[1].checked || delivers[3].checked|| delivers[6].checked|| delivers[7].checked) {
				if (document.getElementById("stores").querySelectorAll(".input-group").length == 0 && !preCheck) {
					util.tips("请填写门店");
					return false;
				}
			}
		}
		if($('#param-items').html()==''){
			util.tips("请填写服务时间");
			return false;
		}
			var inputSJ=$('#param-items td>input:first-child');
		for(var i=0;i<inputSJ.length;i++){
			if(inputSJ[i].value==""){
				util.tips("服务时间不能为空");
				return false;
			}
			var str = inputSJ[i].value;
			var patt1=new RegExp("[0-9][0-9]:[0-9][0-9]","g");
			var re = patt1.test(str);
			if(!re||str.length!=5){
				util.message("时间格式填写错误 "+inputSJ[i].value);
				return false;
			}
			if(i==2||i==4||i==6||i==8||i==10||i==12||i==14||i==16||i==18||i==20||i==22||i==24||i==26||i==28||i==30||i==32){
				var numN=Number(inputSJ[i].value.split(':')[0]+''+inputSJ[i].value.split(':')[1]);
				var numB=Number(inputSJ[i-2].value.split(':')[0]+''+inputSJ[i-2].value.split(':')[1]);
				var numA=Number(inputSJ[i-1].value.split(':')[0]+''+inputSJ[i-1].value.split(':')[1]);
				if(numN>=numB&&numN<=numA){
					util.message("时间段冲突   "+inputSJ[i].value+'在'+inputSJ[i-2].value+'-'+inputSJ[i-1].value+'之间');
					return false;
				}
			}
			if(i==3||i==5||i==7||i==9||i==11||i==13||i==15||i==17||i==19||i==21||i==23||i==25||i==27||i==29||i==31||i==33){
				var numN=Number(inputSJ[i].value.split(':')[0]+''+inputSJ[i].value.split(':')[1]);
				var numB=Number(inputSJ[i-3].value.split(':')[0]+''+inputSJ[i-2].value.split(':')[1]);
				var numA=Number(inputSJ[i-2].value.split(':')[0]+''+inputSJ[i-1].value.split(':')[1]);
				if(numN>=numB&&numN<=numA){
					util.message("时间段冲突   "+inputSJ[i].value+'在'+inputSJ[i-3].value+'-'+inputSJ[i-2].value+'之间');
					return false;
				}
			}
		}
			return true;

		});
	});
</script>
{php include wl_template('common/footer');}